<?php

 global $_GPC, $_W;
       $uniacid = $this->_uniacid;  
       $shopid = $_GPC['shopid'];
       
       /**
        * 获取一条记录
        */
       if(isset($_GPC['enews']) && ($_GPC['enews'] =='detail')){
           
            /*更新浏览*/
            pdo_update('kbwdl_thread', array('click +='=>1), array('id'=> $shopid));
            
            $ret  = pdo_fetch("select * from ".tablename("kbwdl_area")." where uniacid='$uniacid'  and disabled=0 and id='$shopid'");
            $ret['smalltext'] = htmlspecialchars_decode($ret['smalltext']);

            //视频
            if( $ret['thumb']){
                 $ret['thumb'] = tomedia( $ret['thumb']);
            }
              
           
            $this->result(0, 'success', $ret);
       } 
       /**
        * 获取列表
        */
       $keyword = "";
       if($_GPC['keyword']){
            $keyword = $_GPC['keyword'];
       }
       $limit  = 10;
       if(isset($_GPC['limit']) && !empty($_GPC['limit'])){
           $limit = intval($_GPC['limit']);
       }
       $sql_add = " disabled=0 and uniacid='$uniacid' and type=3 ";
      /* if($shopid>0){
            $sql_add.=" and shopid='$shopid' ";
       }   */   
       if($keyword){
           $sql_add.=" and ( name like '%$keyword%'  or address like '%$keyword%')";
       }
       $page = max(1, $_GPC['page']);
       $pagesize = $limit;
       $startlimit = ($page-1)* $pagesize;       
       $ret= pdo_fetchall("select * from ".tablename("kbwdl_area").
               "  where $sql_add order by istop desc,id desc limit $startlimit,$pagesize ");
       if(!empty($ret)){
           foreach($ret as $key=>$val){
               $ret[$key]['thumb'] =  tomedia($val['thumb']);              
           }
       }
       $data['result'] = $ret;
       /*分类统计*/
       
       $data['total'] = pdo_fetchcolumn("select count(*) from ".tablename("kbwdl_shop").
                 " where  $sql_add  ");
       /*是否最后一页*/         
       if($data['total']< $page*$limit){
           $data['islastpage'] = 1;
       }else{
           $data['islastpage'] = 0;
       }      
       $this->result(0, 'success', $data);    
?>
